package openones.mvcportlet.multiforwards.control;

import java.io.IOException;
import java.util.Map;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.PortletException;
import javax.portlet.PortletRequest;

import openones.corewa.BaseOutForm;
import rocky.mvcportlet.control.BaseControl;

public class MenuControl extends BaseControl {

    public BaseOutForm procAdd(ActionRequest request, Map<String, Object> reqMap, ActionResponse response)
            throws PortletException, IOException {
        BaseOutForm outForm = new BaseOutForm();
        Map userInfo = (Map) request.getAttribute(PortletRequest.USER_INFO);
        String logonUser = (String) userInfo.get("user.name.given");
        
        String role = (String) reqMap.get("role");
        LOG.debug("role:" + role);
        if ("admin".equals(role)) {
            outForm.setNextResult("addForAdmin");
        } else { // normal user
            outForm.setNextResult("addForUser");
        }
        return outForm;
    }

}
